package com.solcoo.dao;

import java.sql.SQLException;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Repository;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.solcoo.pojo.MenuType;

@Repository
public class MenuTypeDao {

	@Resource
	private SqlMapClient sqlMapClient;
	
	public boolean addMenuType(MenuType menuType) throws SQLException {
		sqlMapClient.insert("addMenuType", menuType);
		
		if (menuType.getId() != null)
			return true;
		else
			return false;
	}

	public boolean isExist(MenuType menuType) throws SQLException {
		return sqlMapClient.queryForObject("isExist", menuType) != null ? true : false;
	}

	public boolean deleteMenuTypeById(Long id) throws SQLException {
		return sqlMapClient.delete("deleteMenuTypeById", id) > 0 ? true : false;
	}

	public boolean updateMenuType(MenuType menuType) throws SQLException {
		return sqlMapClient.update("updateMenuType", menuType) > 0 ? true : false;
	}

	public MenuType getMenuType(Long id) throws SQLException {
		return (MenuType) sqlMapClient.queryForObject("getMenuType", id);
	}

	public List<MenuType> getMenuTypeListByShanghuid(Long shanghuid) throws SQLException {
		return sqlMapClient.queryForList("getMenuTypeListByShanghuid", shanghuid);
	}
}